<template>
  <div class="room-borrowing-info">
    <div class="edu-page-title" v-if="!dataInfo">
      <el-breadcrumb separator="/">
        {{to}}
        <el-breadcrumb-item :to="{path: '/classroomBorrowingApplication'}" >{{$t('classroomTitle.application')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('classroomTitle.applicationInfo')}}</el-breadcrumb-item>
      </el-breadcrumb>
      <div class="back" style="margin-right: 30px;">
        <!-- <el-button type="text" @click="goback">{{$t('message.return')}}</el-button> -->
        <el-button @click="goback" type="default" icon="el-icon-upload2" >{{$t('message.return')}}</el-button>
      </div>
    </div>
    <el-card shadow="never">
      <h2 class="title">{{$t('classroomTitle.applicationInfo')}}</h2>
      <div>
        <div class="titleFrom">
          <span>{{$t('classroomTitle.basicInfo')}}</span>
          <span class="hideBtn" @click="hideFrom">{{$t('classroomAction.hide')}}</span>
        </div>
        <el-form ref="borrowingInfoFrom" :model="borrowingInfoFrom" :rules="borrowingInfoRules" label-position="right" label-width="130px"  >
          <el-row v-show="isBorrowingFrom">
            <el-col :span="8">
              <el-form-item :label="$t('classroom.borrower')" prop="borPerson">
                <TeacherSelect v-model="borrowingInfoFrom.borPerson" :disabled="isdisabled" @change="handleChange" :condition="teacherSelectCondition" :conditionNotNull="false" :showAllTeacher=true ></TeacherSelect>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item :label="$t('classroom.chargePersonName')" prop="chargePersonName">
                <el-input type="text" v-model="borrowingInfoFrom.chargePersonName" :disabled="true" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item :label="$t('classroom.applyTime')">
                <el-input type="text" v-model="borrowingInfoFrom.applyTimeStr" :disabled="true" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row v-show="isBorrowingFrom">
            <el-col :span="8"><!-- 借用人部门 -->
              <el-form-item :label="$t('classroom.borDepartment')" prop="borDepartment">
                <DictSelect :plzSelect="true" :placeholder="$t('message.plzSelect')" v-model="borrowingInfoFrom.borDepartment" :data="options.borDepartment" :clearable="true" :disabled="isdisabled" ></DictSelect>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item :label="$t('classroom.borContactPhone')">
                <el-input type="text" v-model="borrowingInfoFrom.borContactPhone" maxlength="13" @keypress.native="checkNum" :placeholder="$t('inputPlaceholder')" :disabled="isdisabled" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item :label="$t('classroom.borrowingUse')" prop="borrowingUse">
                <DictSelect :plzSelect="true" :placeholder="$t('message.plzSelect')" v-model="borrowingInfoFrom.borrowingUse" :data="options.borrowingUse" :disabled="isdisabled" :exclude="usageExclude" :clearable="true" ></DictSelect>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row v-show="isBorrowingFrom">
            <el-col :span="8">
              <el-form-item :label="$t('classroom.borExplain')" prop="borExplain">
                <el-input type="text" v-model="borrowingInfoFrom.borExplain" :disabled="isdisabled" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item :label="$t('classroom.otherRequired')">
                <el-input type="text" v-model="borrowingInfoFrom.otherRequired" :disabled="isdisabled" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item class="media" :label="$t('classroom.isMultiMedia')" prop="isMultiMedia">
                <DictSelect :plzSelect="true" :placeholder="$t('message.plzSelect')" v-model="borrowingInfoFrom.isMultiMedia" :data="options.yesOrNo" :clearable="true" :disabled="isdisabled" ></DictSelect>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row v-show="isBorrowingFrom">
            <el-col :span="8">
              <el-form-item :label="$t('classroom.borCampus')" prop="campus">
                <DictSelect :plzSelect="true" :placeholder="$t('message.plzSelect')" v-model="borrowingInfoFrom.campus" :data="options.campus" :clearable="false" :disabled="isdisabled" @change="handelCampusChang" ></DictSelect>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item :label="$t('classroom.attendTotalNumber')" prop="attendTotalNumber">
                <el-input type="text" v-model="borrowingInfoFrom.attendTotalNumber" maxlength="5" @keypress.native="checkNum" :placeholder="$t('inputPlaceholder')" :disabled="isdisabled" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item :label="$t('classroom.classroomNum')">
                <el-input type="text" v-model="borrowingInfoFrom.classroomNum" maxlength="5" @keypress.native="checkNum" :placeholder="$t('inputPlaceholder')" :disabled="isdisabled" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item :label="$t('schoolCalendar.schoolTerm')" prop="calendarId">
                <CalendarSelect v-model="borrowingInfoFrom.calendarId" @load-done="calendarLoadDone" @change="changeCalendar" :disabled="isdisabled" ></CalendarSelect>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item :label="$t('classroom.tower')" prop="towerCode">
                <DictSelect :plzSelect="true" :placeholder="$t('message.plzSelect')" v-model="borrowingInfoFrom.towerCode" :data="teachingBuildingArr" :clearable="true" multiple="true" :disabled="isdisabled" :filterable="true" ></DictSelect>
              </el-form-item>
            </el-col>
          </el-row>

          <!-- 教学周 -->
          <el-row>
            <el-col :span="24">
              <el-form-item :label="$t('courseSummary.teachingWeek')" prop="clsWeek">
                <el-checkbox-group v-model="chooseWeekNum" @change="handleWeekBit">
                  <el-checkbox-button v-for="index in weekNumList" :label="index" :key="index" border size="mini" >
                    <span v-if="index === -1">{{$t('message.all')}}</span>
                    <span v-else>{{index}}</span>
                  </el-checkbox-button>
                </el-checkbox-group>
              </el-form-item>
            </el-col>
          </el-row>

          <!-- 节次 -->
          <el-row>
            <el-form-item :label="$t('label.festivals')" prop="clsSection" class="session">
              <div>
                <!-- <LessonTimeTable :data="borrowingInfoFrom.clsSection" :cellClickCallback="cellClickCallback" ></LessonTimeTable>-->
                <edu-timetableClassRoom :class-data="classData" style="min-width:880px;" :cell-height="30" :color="color" :selected="selected" :actived="activedCell" table-style="1"
                  :disable-time="disableTime" @cell-click="selectData" :legend="{ 'active':$t('arrangement.legend.active'), 'selected': $t('arrangement.legend.unarranged') }" >
                  <!-- 不显示 但是要用 param-switch 组件加载配置数据 -->
                  <span v-show="false" slot="legend" class="float-right" :title="$t('arrangement.tips.globalState')" >
                    {{$t('arrangement.disable9')}}:
                    <param-switch :code="restrictScope==1?'disable9_1':'disable9'" v-model="disable9" ></param-switch>
                  </span>
                </edu-timetableClassRoom>
              </div>
            </el-form-item>
          </el-row>
        </el-form>

        <!-- 按钮功能 -->
        <div class="btnGroup">
          <template v-if="roomBorrowingType === 'view'">
            <el-button class="float-right" type="primary">{{$t('label.back')}}</el-button>
          </template>
          <template v-else-if="!roomBorrowingType">
            <div class="float-left" v-show="pageType != '3'">
              <el-button type="primary" icon="el-icon-check" @click="confirmApplicate" >{{$t('classroomAction.confirmApplication')}}</el-button><!-- 确认申请 -->
            </div>
            <div class="float-right" v-show="pageType != '3'">
              <el-button @click="classroomFormClear" icon="el-icon-close" type="warning">清除已选教室</el-button>
              <el-button type="primary" :disabled="disabledButton" @click="onSubmit" icon="el-icon-search">{{$t('classroomAction.queryClassroom')}}</el-button><!-- 查询教室 -->
            </div>
          </template>
          <div class="clear-both"></div>
        </div>
      </div>
    </el-card>

    <!-- 所选教室changeClassRoom -->
    <el-card shadow="never" body-style="padding: 24px;" class="classRoombackground" v-show="changeClassRoomisShow" style="">
      <h2 class="title">所选教室<span style="margin-right: 1%; float: right; display: inline; font-size: 14px;}">
        教室总数为：{{changeClassRoom_sum}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span v-if="pageType === 1">教室总计容量：{{changeClassRoom_size}}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span v-if="pageType === 1">尚未满足教室要求容量：{{changeClassRoom_length}} </span></span></h2>
      <div>{{changeClassRoom_content}}</div>
    </el-card>

    <!-- 教室信息 -->
    <el-card shadow="never" v-if="showClassroomFlag">
      <h2>{{$t('classroomTitle.classroomInfo')}}</h2>
      <div class="edu-opertion-bar">
        <div class="float-left">
          <el-input v-model="classroomQuery.name" :placeholder="'请输入教室名称'" suffix-icon="el-icon-search" style="width:240px"  @change="onSubmit" />
        </div>
      </div>
      <EduTable ref="stuDataRef" :order="false" :data="classroomList.data" :total="classroomList.total" :pageSize="classroomQuery.pageSize_" :pageNum="classroomQuery.pageNum_" @page-change="pageChange" @selection-change="handleSelectionChange" >
        <el-table-column :label="$t('classroom.name')">
          <template slot-scope="scope">{{scope.row.name}}</template>
        </el-table-column>
        <el-table-column :label="$t('classroom.tower')">
          <template slot-scope="scope">{{scope.row.towerName}}</template>
        </el-table-column>
        <el-table-column :label="$t('classroom.campus')">
          <template slot-scope="scope">{{scope.row.campusI18n}}</template>
        </el-table-column>
        <el-table-column :label="$t('classroom.type')">
          <template slot-scope="scope">{{scope.row.typeI18n}}</template>
        </el-table-column>
        <el-table-column :label="$t('classroom.capacity')">
          <template slot-scope="scope">
            <span v-if="borrowingInfoFrom.borrowingUse == '05'">{{scope.row.examCapacity}}</span>
            <span v-else>{{scope.row.classCapacity}}</span>
          </template>
        </el-table-column>
      </EduTable>
      <div class="text-center" style="margin-top：16px;">
        <!-- 添加教室 -->
        <el-button type="success" :disabled="disabledButton" icon="el-icon-plus" @click="addClassroom">{{$t('classroomAction.addClassroom')}}</el-button>
        <div style="color: red; display: inline;"> （提示：支持分页勾选空闲教室，最后再点击 "添加教室" 按钮）</div>
      </div>
    </el-card>

    <el-card shadow="never" body-style="padding: 24px;" class="card-margin" v-show="pageType == '3'" >
      <h1 class="condition-title">{{$t('classroomTitle.approvalProgress')}}</h1>
      <el-table :data="listApproveHistory" stripe style="width: 100%">
        <el-table-column prop="id" :label="$t('message.order')" width="80" />
        <el-table-column prop="time" :label="$t('message.time')" width="160">
          <template slot-scope="scope">{{ scope.row.time | formatDate }}</template>
        </el-table-column>
        <el-table-column prop="approvorName" :label="$t('classroom.approver')" width="120" />
        <el-table-column prop="groupStr" :label="$t('classroom.role')" width="120" />
        <el-table-column prop="result" :label="$t('classroom.approvorResult')" width="120">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.result == 'Process'" type="success" >{{$t('classroomTitle.processing')}}</el-tag>
            <el-tag v-if="scope.row.result == 'End'" type="info">{{$t('classroomTitle.over')}}</el-tag>
            <el-tag v-if="scope.row.result == 'Reject'" type="warning" >{{$t('classroomTitle.rejected')}}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="oaNo" :label="$t('classroomTitle.oaNumber')" />
        <el-table-column prop="content" :label="$t('classroomTitle.approvalDescription')" show-overflow-tooltip />
        <el-table-column prop="fileInfo" :label="$t('classroomTitle.approvalMaterial')">
          <template slot-scope="scope">
            <div v-if="scope.row.fileInfo">
              <el-button v-for="item in scope.row.fileInfo.approveAttachment" :key="item" type="text" @click="handleGetFile(item)" >{{ item }}</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { queryDic } from "common/src/api/dictionary";
import UTILS from "common/src/utils/utils";
import * as API from "common/src/api/resource/classroom";
import * as indexUtils from "common/src/utils/index";
import filters from "common/src/filters";
import EduTimetableClassRoom from "common/src/components/common/EduTimetableClassRoom";
import { approvelDetail } from "common/src/api/approval";
import mixin from 'common/src/mixins/index';
export default {
  name: "roomBorrowingInfo", mixins: [mixin],
  props: ['dataInfo'],
  filters: {
    formatDate(date) {
      return filters.formatDate(date, "yyyy/MM/dd hh:mm:ss");
    }
  },
  data() {
    const checkNumber = (rule, value, callback) => {
      let reg = /^(0|[1-9]\d*)$/;
      if (!value) {
        return callback(new Error(this.$t("message.inputRequired")));
      }
      if (!reg.test(value)) {
        callback(new Error(this.$t("validateMesagge.mustBeNumber")));
      } else callback();
    };
    return {
      borrowingInfoFrom: {
        borPerson: "",
        borPersonCode: "",
        id: null,
        chargePersonId: "",
        chargePersonName: "",
        applyTime: "",
        applyTimeStr: "",
        borDepartment: "",
        borContactPhone: "",
        borrowingUse: "",
        borExplain: "",
        otherRequired: "",
        isMultiMedia: "",
        campus: "1",
        attendTotalNumber: "",
        classroomNum: "",
        calendarId: "",
        towerCode: [], projectId:"",
        classroomApplyDetailVoList: [] //教室详情
      },
      multipleSelection: [],
      //教室查询条件
      classroomQuery: {
        pageNum_: 1,
        pageSize_: 20,
        calendarId: "",
        campus: "",
        name:"",
        towerCode: "", currentUser:"", projectId:"", newprojectId:"",
        usageCode: "", //空闲教室用途
        weekStart: "", //起始教学周
        weekEnd: "", //最终教学周
        dayOfWeekStart: "", //起始周几
        dayOfWeekEnd: "", //结束周几
        timeStart: "", //起始节次
        timeEnd: "", //结束节次
        classCapacity: "", //出席人数 用途为非排考
        examCapacity: "", //出席人数， 用途为排考的时候
        timeBit: "", //节次二进制
        weekBit: "", //教学周二进制
        weekDayBit: "", //周几二进制
        fixDepartmentList: []
      },
      isBorrowingFrom: true,
      //页面类型 1为新增，2为修改 3为详情
      pageType: "",
      borrowingInfoRules: {
        // borPerson: [ { required: true, message: "请选择借用人名称", trigger: "blur"  } ],
        chargePersonName: [ { required: true, message: "请输入经办人名称", trigger: "blur" } ],
        borDepartment: [ { required: true, message: "请输入借用人部门", trigger: "blur" } ],
        borrowingUse: [ { required: true, message: "请输入借用用途", trigger: "blur" } ],
        borExplain: [ { required: true, message: "请输入借用说明", trigger: "blur" } ],
        // isMultiMedia: [ { required: true, message: "请选择是否使用多媒体设备", trigger: "blur" } ],
        campus: [ { required: true, message: "请选择借用校区", trigger: "blur"  } ],
        attendTotalNumber: [ { required: true, validator: checkNumber, trigger: "blur" } ],
        calendarId: [ { required: true, message: "请选择学期", trigger: "change" } ]
      },
      roomBorrowingType: "", classroomList: { data: [], total: 0 },
      // 下拉框数据
      options: { campus: [], borrowingUse: [], borDepartment: [], yesOrNo: [] },
      teachingBuildingArr: [], path: "",
      //当前学期
      currentTermCalendar: "",
      //当前选择学期总教学周
      totalWeekNumber: "",
      //当前用户信息
      userInfo: {},
      //指定借用教师list
      borPersonsList: [],
      //教学周
      weekNumList: [],
      // 已经选择的教学周
      chooseWeekNum: [],
      //已选择的教室信息
      chooseClassroom: { list: [], tipsStr: "", choosed: "已选" },
      // 当基本信息页面不可编辑的时候，保证教学周多选框也不能编辑
      disableChooseWeekNum: [],
      //节次表的颜色
      color: [ "rgba(255,192,203,0.6)", "rgba(255,255,0,0.5)", "#C0C4CC", "#DCDFE6", "#C0C4CC" ],
      //教室展示信息
      classData: [],
      //已经选择的教室
      selected: [], newprojectId:this.$route.query.newprojectId,
      //已经保存的教室
      saved: [],
      disableTime: [],
      //目前无用
      activedCell: [], isdisabled: false,
      //教室列表是否显示
      showClassroomFlag: false, changeClassRoomisShow: false, listApproveHistory: [], teacherSelectCondition: { pageSize_: 100 },
      //排除教室用途为01,02 为排考模块儿，排课模块儿专用
      usageExclude: ["01", "02"], disabledButton: false,
      // 所选教室(所选教室、教室总数为、教室总计容量、尚未满足教室要求容量)
      changeClassRoom_content:"", changeClassRoom_sum:"0", changeClassRoom_size:"0", changeClassRoom_length:"0"
    };
  },
  components: { EduTimetableClassRoom },
  methods: {
    calendarLoadDone(list) {
      if (list) {
        this.allCalendarList = list;
        for (let index = 0; index < list.length; index++) {
          const element = list[index];
          if (element.currentTermFlag) {
            this.currentTermCalendar = element.id;
            this.totalWeekNumber = element.weekNum;
            this.weekNumList = Array.from({ length: this.totalWeekNumber }).map( (value, index) => index + 1 );
            this.weekNumList.push(-1);
            //清楚之前选择的周的数据
            this.clearWeekData();
            break;
          }
        }
      }
    },
    //每当校历发生变化，动态加载教学周总量
    changeCalendar(val) {
      if (this.allCalendarList) {
        this.allCalendarList.forEach(canlendar => {
          if (canlendar.id === val) {
            this.totalWeekNumber = canlendar.weekNum;
            this.weekNumList = Array.from({ length: this.totalWeekNumber }).map( (value, index) => index + 1 );
            this.weekNumList.push(-1);
            this.clearWeekData();
          }
        });
      }
    },
    checkNum(e) {
      //只输入数字正则
      let reg = /^(0|[1-9]\d*)$/;
      let num = e.target.value || "";
      let str = e.key && e.key != "Unidentified" ? e.key : num.substr(num.length - 1);
      //没有满足任何一种情况，中断执行
      if (reg.test(str)) {
        return true;
      }
      e.returnValue = false;
      return false;
    },
    initOptions() {
      this.options = {
        campus: [],
        borrowingUse: [],
        borDepartment: [],
        yesOrNo: []
      };
      let data = {
        lang: this.$store.getters.language || "cn",
        type: "allChild",
        keys: ["X_XQ", "X_JSYT", "X_YX", "K_SF"]
      };
      queryDic(data).then(res => {
        if (res.code == 200) {
          UTILS.fillSelect(
            {
              campus: "X_XQ",
              borrowingUse: "X_JSYT",
              borDepartment: "X_YX",
              yesOrNo: "K_SF"
            },
            res.data,
            this.options
          );

          // 本科生部门教室借用部门增加学生处、研究生院、团委add by quanwei
          var proid = this.$store.getters.getProjectId();console.log("0.0->proid=" + proid);
          if(proid == 1){
            let newborDepartment = [{key: '000017', value: '000017', label: '学生处'}, {key: '000014', value: '000014', label: '研究生院'}, {key: '000011', value: '000011', label: '团委'} ];
            this.options.borDepartment = this.options.borDepartment.concat(newborDepartment);
          }

          // 默认取管理学院，当管理学院为空时则取所在学院(问题单13195)add by quanwei
          let borDepartment_old = this.borrowingInfoFrom.borDepartment; // 所在学院
          let arr = this.options.borDepartment;
          if(arr.length > 0){
            for (var i = 0; i < arr.length; i++) {
              if(borDepartment_old == arr[i].value){
                // 获取所在部门 add by quanwei(2020年09月08日 15:17:00)
                this.borrowingInfoFrom.borDepartment = String(arr[i].value);
                // 如果管理部门包含所在部门，则取所在部门，显示所在部门
                break;
              }else{
                //this.borrowingInfoFrom.borDepartment = arr[i].value; // 取最后一个管理部门的值update by quanwei(2020年09月08日 15:17:00)
                this.borrowingInfoFrom.borDepartment = ''
              }
          }
            // 此处不使用forEach循环，因为forEach循环不能跳出当前循环
            // arr.forEach(item => {
            //   if(borDepartment_old == item.value){
            //     // 如果管理部门包含所在部门，则取所在部门，显示所在部门
            //   }else{
            //     this.borrowingInfoFrom.borDepartment = item.value; // 取最后一个管理部门的值
            //   }
            // });
          }
        }
      });
    },
    hideFrom() {
      this.isBorrowingFrom = !this.isBorrowingFrom;
    },

    // 确认申请
    confirmApplicate() {
      this.convertApplyDetailData();
      if (this.borrowingInfoFrom.classroomApplyDetailVoList.length == 0) {
        this.$message({ type: "warning", message: "请选择教室后再提交申请!" });
        return;
      }
      let mess = "";
      let changeClassRoom_length = this.changeClassRoom_length;
      if(changeClassRoom_length > 0){
        mess = "尚未满足教室要求容量，还差 "+changeClassRoom_length+" 个，";
      }

      this.$eduConfirm(mess + "确认要提交申请吗？", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" }).then(() => {
        if (this.pageType === "2") { // 1为新增，2为修改 3为详情
          if(!this.isEdit) {
            this.borrowingInfoFrom.classroomApplyDetailVoList = this.classroomApplyDetailVoList;
          }
          API.updateClassroomApply(this.borrowingInfoFrom).then(res => {
            if (res && res.code === 200) {
              this.$message({ type: "success", message: "修改申请单成功!" });
              this.goback();
            } else {
              this.$message({ type: "info", message: "当前借用人所在部门不能进行正常的审批流程！" });
            }
          });
        } else {
          API.creatClassroomApply(this.borrowingInfoFrom).then(res => {
            if (res && res.code === 200) {
              this.$message({ type: "success", message: "创建申请单成功!" });
              this.goback();
            } else {
              this.$message({ type: "info", message: "当前借用人所在部门不能进行正常的审批流程！" });
            }
          });
        }
      }).catch(e => {});
    },
    convertApplyDetailData() {
      // 确认申请  把classData 中的数据 组装成 classroomApplyDetailVoList 要求的样子
      /**
       * classData 格式
       * [{
            "dayOfWeek" : 1,
            "timeStart" : 1,
            "timeEnd" :2,
            "value": this.chooseClassroom.tipsStr,
            "tipsStr":this.chooseClassroom.tipsStr,
            "classroomIds": [1,2,3],
            "timeBit": 32
          }]
        classroomApplyDetailVoList 格式要求
        [{
          "classroomId": 354,
          "classroomApplyId": null,
          "calendarId": 108,
          "weekDayBit": 4,
          "weekBit": 1235,
          "timeBit": 8
      }]
       */
      let classroomApplyDetailVoList = [];
      let tempclassData = this.classData;
      for (let index of tempclassData.values()) {
        for (let classroomId of index.classroomIds.values()) {
          classroomApplyDetailVoList.push({
            classroomId: classroomId,
            classroomApplyId: this.pageType == 2 ? this.classroomQuery.id : null,
            calendarId: this.borrowingInfoFrom.calendarId,
            weekDayBit: 1 << (index.dayOfWeek - 1),
            weekBit: this.classroomQuery.weekBit ? this.classroomQuery.weekBit : this.classroomApplyDetailVoList[0].weekBit,
            timeBit: index.timeBit
          });
        }
      }
      this.borrowingInfoFrom.classroomApplyDetailVoList = classroomApplyDetailVoList;
      // this.borrowingInfoFrom.projectId = this.$store.getters.getProjectId();

      // 当导师即在本科生和研究生都有时则projectId传值 add by quanwei
      this.borrowingInfoFrom.projectId = this.newprojectId;
      if(this.global.isAdmin == true){ // 如果是管理员则projectId取当前部门ID
        this.borrowingInfoFrom.projectId = this.$store.getters.getProjectId();
      }

    },
    classroomFormClear() {
      //清楚已选择的教室、已活动的教室
      this.saved = [];
      this.classData = [];
      this.selected = [];
      this.isEdit = true;
      this.classroomList.data = [];
      this.classroomList.total = 0;
      this.isdisabled = false;
      this.classroomQuery.name = "";
      this.disabledButton = false;
      // 所选教室(所选教室、教室总数为、教室总计容量、尚未满足教室要求容量)
      // changeClassRoom_content:"", changeClassRoom_sum:"", changeClassRoom_size:"", changeClassRoom_length:""
      this.changeClassRoom_content = "";this.changeClassRoom_sum = "0";this.changeClassRoom_size = "0";this.changeClassRoom_length = "0";
    },
    clear() {
      this.borrowingInfoFrom = {
        id: null,
        borPerson: this.userInfo.name,
        borPersonCode: this.userInfo.uid,
        chargePersonId: this.userInfo.uid,
        chargePersonName: this.userInfo.name,
        applyTime: "",
        applyTimeStr: "",
        borDepartment: this.userInfo.faculty,
        borContactPhone: "",
        borrowingUse: "",
        borExplain: "",
        otherRequired: "",
        isMultiMedia: "",
        campus: "1",
        attendTotalNumber: "",
        classroomNum: "",
        towerCode: [],
        calendarId: this.currentTermCalendar,
        classroomApplyDetailVoList: []
      };
      this.classroomQuery = {
        calendarId: this.currentTermCalendar,
        campus: "1",
        name:"",
        weekStart: "",
        weekEnd: "",
        dayOfWeekStart: "",
        dayOfWeekEnd: "",
        timeStart: "",
        timeEnd: "",
        classCapacity: "",
        examCapacity: "",
        timeBit: "",
        weekBit: "",
        weekDayBit: "",
        pageNum_: 1,
        pageSize_: 20
      };
      //选择的教学周
      this.chooseWeekNum = [];
      //学期为当前学期
      // this.$refs.borrowingInfoFrom.resetFields();
      this.borPersonsList = [];
      this.isdisabled = false;
      this.changeClassRoom_content = "";this.changeClassRoom_sum = "0";this.changeClassRoom_size = "0";this.changeClassRoom_length = "0";this.changeClassRoomisShow = false;
    },
    // 返回教室申请页面
    goback() {
      this.clear();
      // this.getAllBorPersonsList();
      this.classroomFormClear();
      this.$store.commit("delete_tabs", this.$route.fullPath);
      this.$router.push({
        path: "/classroomBorrowingApplication"
      });
    },
    // async getAllBorPersonsList(){
    //   let res = await API.getAllTeacherInfo();
    //   if (res && res.code == 200) {
    //     _.forEach(res.data, item => {
    //       this.borPersonsList.push({
    //         value: item.teacherName,
    //         label: item.teacherName
    //       });
    //     });
    //   }
    // },

    // 初始化数据
    initData() {
      //新增页面默认经办人为当前登陆人
      this.classroomApplyDetailVoList = [];
      this.pageType =  this.dataInfo && this.dataInfo.pageType ||  this.$route.query.pageType;
      if (this.pageType === "3") {
        //详情页面
        this.showClassroomFlag = false;
        this.borrowingInfoFrom = this.dataInfo || this.$route.query.applyData;
        approvelDetail({ no: this.borrowingInfoFrom.workflowNo }).then(res => {
          if (res && res.data) {
            let tempdata = res.data.listApproveHistory;
            this.listApproveHistory = tempdata;
            this.listApproveHistory.content = this.borrowingInfoFrom.approvalOpinion;
            this.editDataInit();
          }
        });
      } else if (this.pageType === "2") {
        //修改页面
        this.isEdit = false;
        this.borrowingInfoFrom = this.dataInfo || this.$route.query.applyData;
          this.editDataInit();
      } else {
        this.clear();
        this.classroomFormClear();
        // 获取当前登录用户所有信息
        let user = this.$store.state.session.mockUser;
        this.userInfo = user ? user : JSON.parse(localStorage.getItem("user"));

        // let session = localStorage.getItem("sessiondata");
        // session = JSON.parse(session);
        // this.userInfo = session.mockUser || session.user;

//         let sessiondata = JSON.parse(localStorage.getItem('sessiondata'));
//         if(sessiondata.mockUser) {
//             this.userInfo = sessiondata.mockUser;
//         }else{
//             this.userInfo = sessiondata.user;
//         }

        this.borrowingInfoFrom.applyTime = indexUtils.parseTime( new Date(), "{y}-{m}-{d} {h}:{i}:{s}" );
        this.borrowingInfoFrom.applyTimeStr = this.borrowingInfoFrom.applyTime;
        this.borrowingInfoFrom.chargePersonId = this.userInfo.uid;
        this.borrowingInfoFrom.chargePersonName = this.userInfo.name;
        this.borrowingInfoFrom.borPersonCode = this.userInfo.uid;
        this.borrowingInfoFrom.borPerson = this.userInfo.name;
        this.borrowingInfoFrom.borDepartment = this.userInfo.manageFaculty; // 默认取管理学院，当管理学院为空时则取所在学院add by quanwei

      }
    },
    //初始化申请时间
    editDataInit() {
      let classroomApplyDetailVoList = this.borrowingInfoFrom.classroomApplyDetailVoList;
      this.classroomApplyDetailVoList = this.classroomApplyDetailVoList.length > 0 ? this.classroomApplyDetailVoList : classroomApplyDetailVoList;
      //1 初始化校区值
      this.borrowingInfoFrom.campus = classroomApplyDetailVoList[0].campus;
      //2 初始化校历
      this.borrowingInfoFrom.calendarId = classroomApplyDetailVoList[0].calendarId;
      //3 初始化教学楼
      // this.borrowingInfoFrom.towerCode = classroomApplyDetailVoList[0].towerCode;
      //3 初始化申请时间、这个应保持最新
      if (this.pageType === "2") {
        this.borrowingInfoFrom.applyTime = indexUtils.parseTime( new Date(), "{y}-{m}-{d} {h}:{i}:{s}" );
        this.borrowingInfoFrom.applyTimeStr = this.borrowingInfoFrom.applyTime;
      } else {
        this.borrowingInfoFrom.applyTimeStr = this.borrowingInfoFrom.applyTime;
      }

      //4 教学周初始化
      this.chooseWeekNum = this.getArrayBinary(
        classroomApplyDetailVoList[0].weekBit
      );
      this.disableChooseWeekNum = this.getArrayBinary(
        classroomApplyDetailVoList[0].weekBit
      );
      // this.isdisabled = false; 是为了让教学周的查询条件能初始化，必须要有
      //5 初始化 节次表数据
      let savedList = [];
      for (let index of classroomApplyDetailVoList.values()) {
        //如果 dayOfweek timestart timeEnd 不一样字段一样，添加数据到saved中
        let dayOfWeekList = this.getArrayBinary(index.weekDayBit);
        let timeList = this.getArrayBinary(index.timeBit);
        let tipsStr = index.campusI18n + " " + index.towerName + " " + index.classroomName;
        let dayOfWeek = dayOfWeekList[0];
        let timeStart = Math.min(...timeList);
        let timeEnd = Math.max(...timeList);
        let saved = savedList.filter(x => {
          return ( x.dayOfWeek == dayOfWeek && x.timeStart == timeStart && x.timeEnd == timeEnd );
        });

        if (saved.length == 0) {
          savedList.push({
            dayOfWeek: dayOfWeek,
            timeStart: timeStart,
            timeList: timeList,
            timeEnd: timeEnd,
            value: "已选",
            popover: tipsStr,
            classroomIds: [index.classroomId],
            timeBit: index.timeBit
          });
        } else {
          //返回相同时间维度的数据
          let filtersaved = savedList.filter(x => {
            return !( x.dayOfWeek == dayOfWeek && x.timeStart == timeStart && x.timeEnd == timeEnd );
          });
          let tempdata = saved[0];
          tempdata.classroomIds.push(index.classroomId);
          tempdata.popover = tempdata.popover + "|" + tipsStr;
          filtersaved.push(tempdata);
          savedList = filtersaved;
        }
      }
      this.saved = savedList;
      this.classData = this.saved;
      this.selectCopyData = this.classData;
      //6 设置数据为不可编辑
      this.isdisabled = true;
      this.getClassRoomInfo();
    },
    //把二进制转换成数组
    getArrayBinary(val) {
      let returnList = [];
      let count = 1;
      for (let i = 0; count <= val; i++) {
        if (((1 << i) & val) > 0) {
          returnList.push(i + 1);
        }
        count = count * 2;
      }
      return returnList;
    },
    //处理教学周多选框选中的值
    handleWeekBit(newVal) {
      //如果教学周选择全部
      //如果处于不可编辑状态，则数据保持现状不变
      if (this.isdisabled) {
        this.chooseWeekNum = this.disableChooseWeekNum;
      } else {
        this.disableChooseWeekNum = newVal;
        if (newVal.includes(-1)) {
          this.chooseWeekNum = this.weekNumList;
          this.classroomQuery.weekBit = (1 << (this.weekNumList.length - 1)) - 1;
          this.classroomQuery.weekStart = 1;
          this.classroomQuery.weekEnd = this.weekNumList.length - 1;
        } else if (
          !newVal.includes(-1) &&
          newVal.length == this.weekNumList.length - 1
        ) {
          this.chooseWeekNum = [];
          this.clearWeekData();
        } else {
          this.classroomQuery.weekStart = Math.min(...newVal);
          this.classroomQuery.weekEnd = Math.max(...newVal);
          this.classroomQuery.weekBit = newVal.reduce((sum, value) => {
            return (sum = sum + (1 << (value - 1)));
          }, 0);
        }
      }
    },
    //根据所选择的节次时间设置查询空闲教室的节次参数
    setTimeQueryParamsBySelected() {
      let timeMaps = this.pageType == 2 && !this.isEdit ? this.selectCopyData : this.selected;
      //选中合并后，如果timeStart !==timeEnd,timeEnd参数取值选用合并中的timeEnd参数
      let timeList = Array.from(new Set(timeMaps.map(x => x.timeEnd)));
      let dayOfWeekList = Array.from(new Set(timeMaps.map(x => x.dayOfWeek)));
      //设置查询空闲教室参数
      this.classroomQuery.timeStart = Math.min(...timeList);

      this.classroomQuery.timeEnd = Math.max(...timeList);
      this.classroomQuery.dayOfWeekStart = Math.min(...dayOfWeekList);
      this.classroomQuery.dayOfWeekEnd = Math.max(...dayOfWeekList);
      this.classroomQuery.timeBit = timeList.reduce((sum, value) => {
        return (sum = sum + (1 << (value - 1)));
      }, 0);
      this.classroomQuery.weekDayBit = dayOfWeekList.reduce((sum, value) => {
        return (sum = sum + (1 << (value - 1)));
      }, 0);
    },
    clearWeekData() {
      this.classroomQuery.weekStart = "";
      this.classroomQuery.weekEnd = "";
      this.classroomQuery.weekBit = "";
      if (this.pageType === "2" && this.classroomQuery.weekBit == "") {
        let list = this.chooseWeekNum;
        this.classroomQuery.weekStart = Math.min(...list);
        this.classroomQuery.weekEnd = Math.max(...list);
        this.classroomQuery.weekBit = list.reduce((sum, value) => {
          return (sum = sum + (1 << (value - 1)));
        }, 0);
        if (!list.includes(-1) && list.length == this.weekNumList.length - 1) {
          this.chooseWeekNum.push(-1);
        }
      }
    },
    selectData(day, time, right) {
      //如果当前页面是查看页面
      if (this.pageType === "3") {
        return;
      }
      if (this.saved.length){
        //已经选过教室了，不能第二次选择
        return;
      }
      let saved = this.saved.filter(
        item => item.dayOfWeek == day && item.timeStart == time
      );
      if (right) {
        if (saved.length > 0) {
          // 双击/右击已安排教室
          //提示已选择的教室 不能直接修改，请点击清除按钮重置
          this.$message({ type: "warning", message: "已选择的教室 不能直接修改，请点击清除按钮重置!" });
        } else {
          let deleted = this.selected.filter(
            item => item.dayOfWeek == day && item.timeStart <= time && item.timeEnd >= time
          );
          if (deleted.length > 0) {
            this.selected = this.selected.filter(
              item => !( item.dayOfWeek == day && item.timeStart <= time && item.timeEnd >= time )
            );
          }
        }
      } else {
        //如果是删除带安排教室
        let repeat = this.selected.filter(
          item => item.dayOfWeek == day && item.timeStart <= time && item.timeEnd >= time
        );
        let item;
        if (repeat.length == 0 && saved.length == 0) {
          this.activedCell = [];
          item = { dayOfWeek: day, timeStart: time, timeEnd: time };
          this.selected.push(item);
        }
      }
    },

    // 查询教室
    onSubmit() {
      this.classroomQuery.pageNum_ = 1;
      this.chooseClassroom.list = [];
      this.getQueryClassroom();
    },
    //根据填写内容查询教室
    getQueryClassroom() {
      // 当导师即在本科生和研究生都有时则newprojectId传值 add by quanwei
      this.classroomQuery.newprojectId = this.newprojectId;
      //1 校区、学期id 为必传参数
      let classroomNum = this.borrowingInfoFrom.classroomNum;
      let campus = this.borrowingInfoFrom.campus;
      let calendarId = this.borrowingInfoFrom.calendarId;
      let classroomWeekList = this.chooseWeekNum;
      let usageCode = this.borrowingInfoFrom.borrowingUse;
      let towerCode = this.borrowingInfoFrom.towerCode.toString();
      if ( calendarId != this.currentTermCalendar + 1 && calendarId != this.currentTermCalendar ) {
        this.$message({
          type: "warning",
          message: "只能申请当前学期和下一学期的教室!"
        });
        this.borrowingInfoFrom.calendarId = this.currentTermCalendar;
        return;
      }
      if (campus == "" || calendarId == "") {
        this.$message({
          type: "warning",
          message: "校区和学期为必填值"
        });
        return;
      } else {
        this.classroomQuery.campus = campus;
        this.classroomQuery.calendarId = calendarId;
        this.classroomQuery.usageCode = usageCode;
        this.classroomQuery.towerCode = towerCode;
        //设置教室为可借用
        this.classroomQuery.isBorrow = "1";
        //查询空闲教室只查询本科生院和研究生院的教室:000014为本科生院，000015为研究生院
        this.classroomQuery.fixDepartmentList = ["000014", "000015"];

        //获取当前登录人
         this.classroomQuery.currentUser = this.global.currentUser.uid;
         this.classroomQuery.projectId = this.$store.getters.getProjectId();
      }
      //2 设置出席总人数 如果 用途为排考的，查询教室的时候参数为排考容量、其他则查询排课容量
      if (classroomNum && this.borrowingInfoFrom.borrowingUse === "05") {
        this.classroomQuery.examCapacity = classroomNum;
        this.classroomQuery.classCapacity = "";
      } else {
        this.classroomQuery.classCapacity = classroomNum;
        this.classroomQuery.examCapacity = "";
      }
      //3 如果教学周没选 默认全部教学周
      if (classroomWeekList.length == 0) {
        this.handleWeekBit([-1]);
      }

      //4 节次必选
      if(this.pageType == 2 && !this.isEdit){
        this.setTimeQueryParamsBySelected();
      }else {
        if (this.selected.length == 0) {
          this.$message({ type: "warning", message: "请选择教室的借用节次" });
          return;
        } else {
          this.setTimeQueryParamsBySelected();
        }
      }

      if (!this.isdisabled) {
        this.$confirm( "点击查询教室，便不可修改申请单基础信息，请确认！", this.$t("message.confirm"), {
            distinguishCancelAndClose: false,
            confirmButtonText: this.$t("message.confirm"),
            cancelButtonText: this.$t("message.cancel")
          }
        ).then(() => {
          //3 根据条件查询空闲教室
          this.$refs["borrowingInfoFrom"].validate(valid => {
            if (valid) {
              this.isdisabled = true;
              API.getCanBorrowClassroomIList(this.classroomQuery).then(res => {
                if (res && res.code == 200) {
                  this.classroomList.data = res.data.list;
                  this.multipleSelection = [];
                  setTimeout(() => {
                    this.classroomList.data.forEach(row => {
                        // if(row.imported){
                        // this.$refs.stuDataRef.toggleRowSelection(row, true);
                        // this.pageSelectList.push(row);
                        // } else {
                        // this.$refs.stuDataRef.toggleRowSelection(row, false);
                        // }
                        let isRowSelect = false;
                        this.chooseClassroom.list.forEach(item => {
                            if(row.id == item.id) {
                                isRowSelect = true;
                            }
                        })
                        if(isRowSelect) {
                            this.$refs.stuDataRef.toggleRowSelection(row, true);
                            // this.pageSelectList.push(row);
                        } else {
                            this.$refs.stuDataRef.toggleRowSelection(row, false);
                        }
                    });
                  },1)
                  this.classroomList.total = res.data.total_;
                  this.classroomQuery.pageSize_ = res.data.pageSize_;
                  this.classroomQuery.pageNum_ = res.data.pageNum_;
                  this.showClassroomFlag = true;
                }
              });
            }
          });
        });
      } else {
        API.getCanBorrowClassroomIList(this.classroomQuery).then(res => {
          if (res && res.code == 200) {
            this.classroomList.data = res.data.list;
            this.multipleSelection = [];
            setTimeout(() => {
              this.classroomList.data.forEach(row => {
                  // if(row.imported){
                  // this.$refs.stuDataRef.toggleRowSelection(row, true);
                  // this.pageSelectList.push(row);
                  // } else {
                  // this.$refs.stuDataRef.toggleRowSelection(row, false);
                  // }
                  let isRowSelect = false;
                  this.chooseClassroom.list.forEach(item => {
                      if(row.id == item.id) {
                          isRowSelect = true;
                      }
                  })
                  if(isRowSelect) {
                      this.$refs.stuDataRef.toggleRowSelection(row, true);
                      // this.pageSelectList.push(row);
                  } else {
                      this.$refs.stuDataRef.toggleRowSelection(row, false);
                  }
              });
            },1)
            this.classroomList.total = res.data.total_;
            this.classroomQuery.pageSize_ = res.data.pageSize_;
            this.classroomQuery.pageNum_ = res.data.pageNum_;
            this.showClassroomFlag = true;
          }
        });
      }
    },
    handleSelectionChange(val) {
      let delList = this.multipleSelection.filter(item => {
          return val.map(ele => {
            return ele.id
          }).indexOf(item.id) < 0
      })
      let addList = val.filter(item => {
        return this.multipleSelection.map(ele => {
          return ele.id
        }).indexOf(item.id) < 0
      })
      if(delList.length > 0) {
        this.chooseClassroom.list = this.chooseClassroom.list.filter(item => {
          return delList.map(ele => {
            return ele.id
          }).indexOf(item.id) < 0
        })
      }
      if(addList.length >0) {
        let addRowsList = addList.filter(item => {
          return this.chooseClassroom.list.map(ele => {
            return ele.id
          }).indexOf(item.id) < 0
        })
        if (addRowsList.length > 0) {
          this.chooseClassroom.list = this.chooseClassroom.list.concat(addRowsList)
        }
      }
      this.multipleSelection  = val;
      // this.chooseClassroom.list = val;
      let tipsStr = this.chooseClassroom.list.reduce((str, value) => {
        return (str =  str + value.campusI18n + " " + value.towerName + " " + value.name + "|"); }, "");
      this.chooseClassroom.tipsStr = tipsStr.substr(0, tipsStr.length - 1);
      this.chooseClassroom.choosed = "已选";
    },
    // 分页功能
    pageChange(val) {
      this.classroomQuery.pageNum_ = val.pageNum;
      this.classroomQuery.pageSize_ = val.pageSize;
      this.getQueryClassroom();
    },
    // 添加教室
    addClassroom() {

      //清楚已选择的教室、已活动的教室
      // ------------(新)------------------
      // this.saved = [];
      // this.classData = [];
      // ------------(新)------------------

      this.mergeData();
      this.saved = _.cloneDeep(this.selected);
      //以星期几维度合并节次,让数据简化
      this.classData = this.saved;
      //清空
      // ------------(旧)------------------
      //this.selected = [];
      //this.showClassroomFlag = false;
      // ------------(旧)------------------
      this.disabledButton = true;

      // 动态添加以选择的教室数据显示在“所选教室”
      // 所选教室(所选教室、教室总数为、教室总计容量、尚未满足教室要求容量)
      this.getClassRoomInfo();
      let arr = this.chooseClassroom.list.map(x => x.classCapacity);
      let size = 0;
      arr.forEach(item => {
        size = item + size;
      });
      this.changeClassRoom_size = size; // 教室总计容量
      this.changeClassRoom_length = (this.borrowingInfoFrom.attendTotalNumber - size) < 0 ? 0 : this.borrowingInfoFrom.attendTotalNumber - size; // 尚未满足教室要求容量
      this.isEdit = true;
    },
    getClassRoomInfo() {
      let content = "";
      //let content2 = this.chooseClassroom.tipsStr; console.log("content2==="+content2);
      this.classData.forEach(el => { content = el.popover + "|" + content});
      let contentList = content.slice(0,content.length-1).split("|");
      contentList = contentList.filter(function(item, index) {
          return contentList.indexOf(item) === index
      })
      content = contentList.join("|");
      this.changeClassRoom_sum = !content ? '0' : content.split("|").length;

      content = content.replace(/\|/g, '，'); //\为转义字符 g表示全局
      console.log("content==="+content);
      this.changeClassRoom_content = content; // 所选教室All
      this.changeClassRoomisShow = true;
    },
    //以星期几维度合并节次,让数据简化
    mergeData() {
      let selected = this.pageType == 2 && !this.isEdit ? this.selectCopyData : this.selected;
      let resultData = [];
      for (let index of [1, 2, 3, 4, 5, 6, 7].values()) {
        let weekDayList = selected.filter(item => item.dayOfWeek == index);
        // let timeList = this.pageType == 2 && !this.isEdit ? selected[0].timeList : weekDayList.map(item => item.timeStart);

        let timeList = []
        if(weekDayList.length > 0) {
          // timeList = this.pageType == 2 && !this.isEdit ? selected[index].timeList : weekDayList.map(item => item.timeStart);
          timeList =
              this.pageType == 2 && !this.isEdit
              ?
              selected.find(item => {if (item.dayOfWeek == weekDayList.find(item => {return item.dayOfWeek}).dayOfWeek){return item.timeList}}).timeList
              :
              weekDayList.map(item => item.timeStart);
        }
        if (timeList.length > 0) {
          timeList = this.splitData(timeList.sort((a, b) => a - b));
          for (let value of timeList.values()) {
            resultData.push({
              dayOfWeek: index,
              timeStart: Math.min(...value),
              timeEnd: Math.max(...value),
              // "value": this.chooseClassroom.choosed,
              value: this.chooseClassroom.choosed,
              popover: this.chooseClassroom.tipsStr,
              classroomIds: this.chooseClassroom.list.map(x => x.id),
              timeBit: value.reduce((sum, value) => {
                return (sum = sum + (1 << (value - 1)));
              }, 0)
            });
          }
        }
      }
      this.selected = resultData;
    },
    //把不连续的数组切割成连续的数组
    splitData(arr) {
      var result = [], i = 0;
      result[i] = [arr[0]];
      arr.reduce(function(prev, cur) {
        cur - prev === 1 ? result[i].push(cur) : (result[++i] = [cur]);
        return cur;
      });
      return result;
    },
    handleChange(val) {
      this.borrowingInfoFrom.borPerson = val.name;
      this.borrowingInfoFrom.borPersonCode = val.code;
      this.borrowingInfoFrom.borDepartment = val.faculty;
    },
    handelCampusChang(item = null) {
      this.teachingBuildingArr = [];
      this.borrowingInfoFrom.towerCode = [];
      this.classroomQuery.towerCode = "";
      let params = {
        campus: this.borrowingInfoFrom.campus,
        // departmentCode: this.borrowingInfoFrom.borDepartment,
        //maintainable 后台接受参数为true查询只有公共教室的教学楼，false为查询全部教室
        maintainable:true
      };
      API.conditionQueryByDict(params).then(res => {
        if (res && res.code == 200) {
          let dataList = res.data.list;
          dataList.forEach(item => {
            this.teachingBuildingArr.push({ value: item.code, label: item.name });
          });
        }
      });
    }
  },
  watch: {
    $route() {
      //1 表示此页面为新增页面
      this.initData();
    }
  },
  created() {
    // this.getAllBorPersonsList();
    this.initOptions();
    console.log("2.1->newprojectId=" + this.newprojectId);
    this.handelCampusChang(this.borrowingInfoFrom.campus);
    this.initData();
  }
};
</script>

<style lang="scss" scoped>
.room-borrowing-info {
  .edu-page-title {
    .back {
      text-align: right;
      margin-bottom: 16px;
    }
  }
  .title {
    padding-bottom: 16px;
    border-bottom: 1px solid #dcdcdc;
  }
  .titleFrom {
    height: 32px;
    line-height: 32px;
    span {
      margin-left: 16px;
    }
    .hideBtn {
      color: #3a7fe8;
      cursor: pointer;
    }
  }
  .btnGroup {
    margin-top: 16px;
    padding: 0 130px;
  }
  ::v-deep .el-input__inner{
    color: #2b3b4e !important;
  }
}
</style>
<style lang="scss">
.room-borrowing-info {
  .media {
    .el-form-item__label {
      line-height: 16px;
      height: auto;
    }
  }
  .session {
    .el-form-item__content {
      line-height: auto;
      height: auto;
    }
  }
  .classRoombackground{
    background: url('/static/images/classRoombackground.png') no-repeat;
    background-size: 100%;
  }
}
</style>
